﻿using System.Runtime.Caching;

namespace Utils
{
    public class CacheHelper
    {
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="Key"></param>
        /// <param name="Value"></param>
        public static void WriteToSystemCache(string Key, object Value)
        {
            MemoryCache cache = MemoryCache.Default;
            CacheItem item = new CacheItem(Key, Value);
            CacheItemPolicy policy = new CacheItemPolicy() { AbsoluteExpiration = DateTime.Now.AddDays(3) };
            cache.Set(item, policy);
        }

        public static object ReadFromSystemCache(string Key)
        {
            MemoryCache cache = MemoryCache.Default;
            object Value = cache.Get(Key);
            return Value;
        }
    }
}